<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <input type="text" id="input1">
        <button id="btn">获取值</button>
    </div>
</body>
<script>
    const input = document.querySelector("#input1");
    const btn = document.querySelector("#btn");

    const obj = {}

    input.addEventListener("input",function(e) {
        obj.text = input.value;
    });

    btn.addEventListener("click",function() {
        console.log("文本框的值：",obj.text);
    })

    Object.defineProperty(obj,"text",{
        set(value) {
            input.value = value;
            text = value;
        },
        get() {
            return text;
        }
    })
    obj.text = "请填入想要查询的内容"; 
</script>
</html>